﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Isaac.Joy.Menu.Module;

namespace Isaac.Joy.WebFramework.DtCms.Controllers
{
    public class MenusController : Controller
    {
        /// <summary>
        /// 树状结构的局部视图
        /// </summary>
        /// <param name="childrens"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        public ActionResult Tree(IEnumerable<IMenu> childrens, int level)
        {
            childrens = childrens.OrderBy(x => x.Order);
            ViewBag.Level = level;
            return View(childrens);
        }

        /// <summary>
        /// 弹出菜单的局部视图
        /// </summary>
        /// <param name="childrens"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        public ActionResult Pop(IEnumerable<IMenu> childrens, int level)
        {
            childrens = childrens.OrderBy(x => x.Order);
            ViewBag.Level = level;
            return View(childrens);
        }
    }
}
